import datetime

from pydantic import BaseModel
from typing import List, Optional, Dict

"""
单元基本信息上传数据模型
"""


# 子模型 增、改
class SubDvpUnitBasic(BaseModel):
    DvpUnit_ID: str
    DvpUnit_Name: str
    Belong_DvpUnit_Name: str
    DvpUnit_Rank: str
    Remark: str


# 子模块 删
class SubDvpUnitBasicDel(BaseModel):
    DvpUnit_ID: str
    DvpUnit_Name: str


# 嵌套参数
class DvpUnitBasic(BaseModel):
    save: Optional[List[SubDvpUnitBasic]] = None
    modify: Optional[List[SubDvpUnitBasic]] = None
    delete: Optional[List[SubDvpUnitBasicDel]] = None


"""
单井基本信息上传数据模型
"""


# 子模型 增、改
class SubWellBasic(BaseModel):
    Well_ID: int
    Well_Name: str
    GeoCoordX: float
    GeoCoordY: float
    Belong_DvpUnit_Name: str
    Remark: str


# 子模块 删
class SubWellBasicDel(BaseModel):
    Well_ID: int
    Well_Name: str


# 嵌套参数
class WellBasic(BaseModel):
    save: Optional[List[SubWellBasic]] = None
    modify: Optional[List[SubWellBasic]] = None
    delete: Optional[List[SubWellBasicDel]] = None


"""
措施分类信息上传数据模型
read_oil_well_stimulate_data
"""


class SubOilWellStimulate(BaseModel):
    StimType_ID: int
    StimType_Name: str
    Belong_StimType_Name: str
    StimType_Rank: str
    Remark: str


class SubOilWellStimulateDel(BaseModel):
    StimType_ID: int
    StimType_Name: str


class OilWellStimulate(BaseModel):
    save: Optional[List[SubOilWellStimulate]] = None
    modify: Optional[List[SubOilWellStimulate]] = None
    delete: Optional[List[SubOilWellStimulateDel]] = None


"""
单元措施效果上传数据模型
read_unit_stimulate_result_data
"""


class SubUnitStimulateResult(BaseModel):
    DvpUnit_Name: str
    Year: str
    StimType_Name: str
    Stim_WellNumber_Valid: int
    Stim_WellValidRatio: float
    Stim_ValidPeriod_Average: int
    Stim_IncreOil_Average: float
    Remark: str


class SubUnitStimulateResultDel(BaseModel):
    DvpUnit_Name: str
    Year: str
    StimType_Name: str


class UnitStimulateResult(BaseModel):
    save: Optional[List[SubUnitStimulateResult]] = None
    modify: Optional[List[SubUnitStimulateResult]] = None
    delete: Optional[List[SubUnitStimulateResultDel]] = None


"""
单井措施效果上传数据模型
read_well_stimulate_result_data
"""


class SubWellStimulateResult(BaseModel):
    Well_Name: str
    Stim_Date: datetime.date
    StimType_Name: str
    Stim_ValidPeriod: int
    Stim_IncreOil: float
    Remark: str


class SubWellStimulateResultDel(BaseModel):
    Well_Name: str
    Stim_Date: datetime.date
    StimType_Name: str


class WellStimulateResult(BaseModel):
    save: Optional[List[SubWellStimulateResult]] = None
    modify: Optional[List[SubWellStimulateResult]] = None
    delete: Optional[List[SubWellStimulateResultDel]] = None


"""
措施作业费用上传数据模型
read_stimulate_cost_data
"""


class SubStimulateCost(BaseModel):
    DvpUnit_Name: str
    Year: str
    StimType_Name: str
    Stim_Cost: float
    Remark: str


class SubStimulateCostDel(BaseModel):
    DvpUnit_Name: str
    Year: str
    StimType_Name: str


class StimulateCost(BaseModel):
    save: Optional[List[SubStimulateCost]] = None
    modify: Optional[List[SubStimulateCost]] = None
    delete: Optional[List[SubStimulateCostDel]] = None


"""
单元原油价格上传数据模型
read_unit_oil_price_data
"""


class SubUnitOilPrice(BaseModel):
    DvpUnit_Name: str
    Year: str
    Oil_CommodityRatio: float
    Oil_Price: float
    Remark: str


class SubUnitOilPriceDel(BaseModel):
    DvpUnit_Name: str
    Year: str


class UnitOilPrice(BaseModel):
    save: Optional[List[SubUnitOilPrice]] = None
    modify: Optional[List[SubUnitOilPrice]] = None
    delete: Optional[List[SubUnitOilPriceDel]] = None


"""
增油操作成本上传数据模型
read_oil_operate_cost_data
"""


class SubOilOperateCost(BaseModel):
    DvpUnit_Name: str
    Year: str
    Oil_OprCost: float
    FuelCost: float
    Power_Cost: float
    FluidDispose_Cost: float
    OilDisplaceAgent_Cost: float
    NGLRecovery_Cost: float
    Transp_Cost: float
    WellTest_Cost: float
    Other_Cost: float
    Depre_Cost: float
    Remark: str


class SubOilOperateCostDel(BaseModel):
    DvpUnit_Name: str
    Year: str


class OilOperateCost(BaseModel):
    save: Optional[List[SubOilOperateCost]] = None
    modify: Optional[List[SubOilOperateCost]] = None
    delete: Optional[List[SubOilOperateCostDel]] = None


"""
增油销售成本上传数据模型
read_oil_sale_cost_data
"""


class SubOilSaleCost(BaseModel):
    DvpUnit_Name: str
    Year: str
    OilSale_TotalTaxRatio: float
    AddedValue_TaxRatio: float
    Resource_TaxRatio: float
    EduAdd_TaxRatio: float
    CityDvpAdd_TaxRate: float
    Income_TaxRate: float
    ManageCost_Ratio: float
    Remark: str


class SubOilSaleCostDel(BaseModel):
    DvpUnit_Name: str
    Year: str


class OilSaleCost(BaseModel):
    save: Optional[List[SubOilSaleCost]] = None
    modify: Optional[List[SubOilSaleCost]] = None
    delete: Optional[List[SubOilSaleCostDel]] = None


"""
资金成本上传数据模型
read_cost_data
"""


class SubCost(BaseModel):
    DvpUnit_Name: str
    Year: str
    Money_Discount: float
    Remark: str


class SubCostDel(BaseModel):
    DvpUnit_Name: str
    Year: str


class Cost(BaseModel):
    save: Optional[List[SubCost]] = None
    modify: Optional[List[SubCost]] = None
    delete: Optional[List[SubCostDel]] = None


"""
单元经济评价结果数据模型
read_unit_stimulate_evaluate_result_data
"""


class SubUnitStimulateEvaluateResult(BaseModel):
    DvpUnit_Name: str
    Year: str
    StimType_Name: str
    Stim_WellValidRatio: float
    Stim_WellNumber_Valid: int
    Stim_ValidPeriod_Average: int
    Stim_IncreOil_Average: float
    StimCost_Average: float
    StimOil_OprCost_Average: float
    StimOil_CommodityRatio: float
    StimOil_Gross_SalesIncome_Average: float
    StimOil_Total_TaxRatio_Average: float
    StimOil_Static_Gains_Average: float
    StimOil_NPV_Average: float
    StimOil_ROI: float
    StimOil_NPVR: float
    StimOil_FIRR: float
    Stim_IncreOil_Critical_Average: float
    StimOil_Price_Critical_Average: float
    Oil_Price: float
    OilSale_TotalTaxRatio: float
    Money_Discount: float
    Oil_OprCost: float
    StimOil_Price_Critical: float
    StimOil_WellOprCost_Average: float
    Remark: str


class SubUnitStimulateEvaluateResultDel(BaseModel):
    DvpUnit_Name: str
    Year: str


class UnitStimulateEvaluateResult(BaseModel):
    save: Optional[List[SubUnitStimulateEvaluateResult]] = None
    modify: Optional[List[SubUnitStimulateEvaluateResult]] = None
    delete: Optional[List[SubUnitStimulateEvaluateResultDel]] = None


"""
单井经济评价结果数据模型
read_well_stimulate_evaluate_result_data
"""


class SubWellStimulateEvaluateResult(BaseModel):
    Well_Name: str
    Stim_Date: datetime.date
    StimType_Name: str
    Stim_ValidPeriod: int
    Stim_IncreOil: float
    StimCost: float
    StimOil_WellOprCost: float
    StimOil_CommodityRatio: float
    StimOil_Gross_SalesIncome: float
    StimOil_Total_Tax: float
    StimOil_Static_Gains: float
    StimOil_NPV: float
    StimOil_ROI: float
    StimOil_NPVR: float
    StimOil_FIRR: float
    Stim_IncreOil_Critical: float
    StimOil_Price_Critical: float
    Oil_Price: float
    OilSale_TotalTaxRatio: float
    Money_Discount: float
    Oil_OprCost: float
    Remark: str


class SubWellStimulateEvaluateResultDel(BaseModel):
    Well_Name: str
    Stim_Date: datetime.date
    StimType_Name: str


class WellStimulateEvaluateResult(BaseModel):
    save: Optional[List[SubWellStimulateEvaluateResult]] = None
    modify: Optional[List[SubWellStimulateEvaluateResult]] = None
    delete: Optional[List[SubWellStimulateEvaluateResultDel]] = None
